#ifndef PLAYER_CONTROLLER_H
#define PLAYER_CONTROLLER_H

#include <iostream>
#include <map>
#include <string>

#include "SFML/Graphics.hpp"

//#include "BaseController.h"
#include "Player.h"
#include "Weapon.h"
#include "Camera.h"
//class Level;

class PlayerController
//: public BaseController
{
public:
    PlayerController();
    PlayerController(PlayerPtr player, CameraPtr camera, const std::string& playerDataFn);

    void update(float delta);

	// updates player based on input.
	void update(const sf::RenderWindow& window);

    void draw(sf::RenderWindow& window);
    //virtual void onStarted();
    //virtual void onIntermission(bool isFirstLoaded, Level& newLevel, const sf::Vector2i& entryPoint);
    //virtual void onFinished();

    //virtual void readFile(const boost_path& fileName);
	//virtual void writeFile(const boost_path& fileName) const;

    //PlayerPtr getPlayer();
    //void setPlayer(PlayerPtr player);

    void setSelectedWeapon(/*weapon*/);
    void scrollSelectedWeapon(bool up);

    //void pickupItem(Inventory& sourceInv, const ItemStack& item);
    //void dropItem(const ItemStack& item);

    //bool isEquipped(const Item& item) const;
    //// Adds item to appropriate slot, removing currently equipped item (if any).
    //// Returns currently equipped item (if any).
    //optional_item equipItem(const Item& item);
    //// Removes item from appropriate slot and adds to inventory.
    //void unequipItem(const Item& item);

    enum PLAYER_SOUND
    {
        PICKED_UP_ITEM,
        DROPPED_ITEM,
        EQUIPPED_ITEM,
        UNEQUIPPED_ITEM
    };
private:
    friend std::istream& operator>>(std::istream& stream, PLAYER_SOUND& type);
    friend std::ostream& operator<<(std::ostream& stream, const PLAYER_SOUND& type);
      
    virtual void fireSelectedWeapon(const sf::Vector2i& targetPos); // In pixels.
    virtual void jump();
    CameraPtr camera;
    sf::Vector2f actualGravity;
    sf::Vector2f gravity;
    bool wasSpaceDown;

    //void playSound(PLAYER_SOUND sound);

    //PlayerPtr player;
    //Level* currentLevel;

    //DelayTimer mouseClickDelay;
        
    // Whether the player will respond to interaction.
    bool responsive;

    bool switchingLevels;

    //typedef std::map<PLAYER_SOUND, SoundPtr> PlayerSoundMap;
    //typedef PlayerSoundMap::iterator SoundIt;
    //typedef PlayerSoundMap::const_iterator constSoundIt;

    //PlayerSoundMap playerSounds;

    // Player to control.
    PlayerPtr player;

    // Weapon object
    Weapon weapon;
    //TESTING (can be new class (Hand)
    AnimatedSprite hand;
};

#endif